put ScrollBar(true, true, false, 0, 7, orig, 1) into new
if new <> orig then
put VolumeLevel(new) into it
play "Boing"
end if
end mouseDown
on initBar
put ScrollBar(false, true, false, 0, 7, VolumeLevel(), -1) into it
end initBar
-- part 2 (button)
-- low flags: 00
-- high flags: 8001
-- rect: left=394 top=165 right=212 bottom=454
-- title width / last selected line: 0
-- icon id / first selected line: 12694 / 12694
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Sample Tune
----- HyperTalk script -----
on mouseUp
global Tempo, Pitch
put 210 into Tempo
put 4 into Pitch
playTune
set the name of me to "Stop Sample"
set the icon of me to "Sp 0"
repeat forever
if the sound is "done" or the mouse is "down" then exit repeat
end repeat
play stop
set the name of me to "Sample Tune"
set the icon of me to "Music Note"
end mouseUp
-- part 3 (field)
-- low flags: 81
-- high flags: 0007
-- rect: left=15 top=15 right=273 bottom=497
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 4
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name: Script
-- part contents for background part 3
----- text -----
The scroll bar adjusts the volume level of the Mac using my VolumeLevel() XFCN. ScrollBar() is called using a mouseDown handler so the scroll bar is not activated unless a click occurs over the bar, this also means that the cursor will not change to an arrow in the scroll region until the button is clicked. No call back is used.
The parent object of the scroll bar is a field — just to demonstrate the use of ScrollBar() from fields…
-- part contents for card part 3
----- text -----
Script of scroll bar field:
on mouseDown
put VolumeLevel() into orig
put ScrollBar(true, true, false, 0, 7, orig, 1) into new
if new <> orig then
put VolumeLevel(new) into it
play "Boing"
end if
end mouseDown
on initBar
put ScrollBar(false, true, false, 0, 7, VolumeLevel(), -1) into it